package sample;
import javafx.scene.control.TextArea;
import java.awt.*;
import java.util.LinkedList;

public class RR {
    //轮转round-robin
    public RR(LinkedList<PCB> pcblist, TextArea txtprocess){
        int i;
        while (!pcblist.isEmpty()){
                pcblist.getFirst().setTime(pcblist.getFirst().getTime()-1);
                if (pcblist.getFirst().getTime()<=0)
                    pcblist.getFirst().setStatus(-1);
                PCB temp=pcblist.remove(0);
                    pcblist.add(temp);
            for ( i = 0; i < pcblist.size(); i++) {
                txtprocess.appendText(pcblist.get(i).print_pcb());
            }
            if (pcblist.getLast().getStatus()==-1) {
                pcblist.remove(pcblist.size()-1);
            }
            txtprocess.appendText("---------------------------------------------------------------------------------------\n");
        }
    }
}
